<template>
	<view class="doctorAdvice">
		<view class="patientList" v-for="(item) in bedPatientList" :key="item.id">
			<view class="baseInfo" @click="goInfoFn(item)">
				<view class="name">
					{{item.patientName}}
					<up-icon name="woman" style="margin-left: 6rpx;margin-top: 10rpx;" size='20' color='pink'
						v-if='item.patientSex=="女"'></up-icon>
					<up-icon name="man" v-if='item.patientSex=="男"' style="margin-left: 6rpx;margin-top: 10rpx;" size='20'
						color='skyblue'></up-icon>
				</view>
				<view class="name">
					{{item.bedNo}}床
				</view>
			</view>
			<view class="baseInfo">
				<view class="Num">
					<view class="bedNum">
						年龄：
					</view>
					{{item.patientAge}}岁
				</view>
				<view class="Num">
					<view class="bedNum">
						就诊卡号：
					</view>
					{{item.medicalNum}}
				</view>
			</view>
		</view>

	</view>
</template>

<script setup>
	import {
		ref,
		reactive,
		toRefs,
	} from 'vue'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		getCmdInfoAPI,
		executeCmdAPI,
		getBedPatientInfoAPI
	} from "../../../api/reserveResources.js"

	const state = reactive({
		bedPatientList: [],
	})
	const {
		bedPatientList,
	} = toRefs(state)
	onLoad(() => {
		console.log('进入了页面');
		// 获取床位信息
		getBedPatientInfoFn()
	})
	const getBedPatientInfoFn = async () => {
		let res = await getBedPatientInfoAPI({
			department: '抢救室'
		})
		console.log(res ,'res');
		if (res.code == 200) {
			if (res.data.length > 0) {
				
				bedPatientList.value = []
				res.data.map(item => {
					if (item.patientInfo) {
						bedPatientList.value.push({
							patientAge: item.patientInfo?.patientAge,
							patientName: item.patientInfo?.patientName,
							patientSex: item.patientInfo?.patientSex,
							id: item.patientInfo?.id,
							medicalNum: item.patientInfo?.medicalNum,
							bedNo: item.patientInfo?.bedNo,
							hospitalId:item.patientInfo?.hospitalId,
						})
					}
				})
				console.log(bedPatientList.value ,'bedPatientList.value ');
			}
			console.log(bedPatientList.value, 'bedPatientList.value');
			// bedPatientList.value = res.data
		}
		// getBedPatientInfoAPI
	}
	// 点击前往
	const goInfoFn = (item) => {
		uni.navigateTo({
			url: `/pages/reserveResources/doctorAdvice/patientInfo?info=${JSON.stringify(item)}`
		})
	}
</script>

<style scoped lang="scss">
	page {
		height: 100%;
		width: 100%;
		color: #393e46;
	}

	.doctorAdvice {
		height: 100%;
		background-color: #eefdfb;
		padding: 30rpx;
		box-sizing: border-box;

		.patientList {
			border-radius: 20rpx;
			padding: 20rpx 40rpx;
			background-color: #fff;
			margin-bottom: 30rpx;

			.baseInfo {
				display: flex;
				justify-content: space-between;
				margin-bottom: 20rpx;

				.name {
					display: flex;
					font-size: 50rpx;
					font-weight: 600;
				}

				.Num {
					display: flex;
					align-items: center;

					.bedNum {
						color: #898a89;
						font-size: 26rpx;
					}
				}
			}
		}

		.execute {}

	}
</style>